from abc import abstractmethod, ABC
from typing import Literal, TypeVar, Generic
from aiohttp import web
from ..logger import AbstractLogger


ContextType = TypeVar('ContextType')


class HttpEndpointDescriptor(ABC, Generic[ContextType]):
    @property
    @abstractmethod
    def path(self) -> str:
        pass

    @property
    @abstractmethod
    def method(self) -> str:
        pass

    async def on_prepare(self, *, context: ContextType, logger: AbstractLogger):
        pass

    @abstractmethod
    async def on_request(self, *, context: ContextType, logger: AbstractLogger, request: web.Request) -> web.Response:
        pass